package cn.wolfcode.crm.util;

import org.springframework.util.StringUtils;

import java.lang.reflect.Method;

/**根据method方法生成权限表达式
 * Created by GG on 2020/3/16.
 */
public class PermissionUtil  {
    public static String handlerExpression(Method method){
        String simpleName = method.getDeclaringClass().getSimpleName();//获取的是类似DepartmentController
        simpleName=simpleName.replace("Controller","");//Depertment
        simpleName= StringUtils.uncapitalize(simpleName);//spring方法,把首字母转成小写
        //获取到department下的方法,比如list
        // String methodName = method.getName();//list
        String methodName = method.getName();//list
        String expression = simpleName + ":" + methodName;//department:list
        return expression;
    }

}
